package com.tepth.maintenancesystem.presenter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.superrecycleview.superlibrary.adapter.BaseViewHolder;
import com.superrecycleview.superlibrary.adapter.SuperBaseAdapter;
import com.tepth.maintenancesystem.R;
import com.tepth.maintenancesystem.bean.VehicleObj;

import java.util.List;

/**
 * Created by LHQ on 2016/11/28.
 */

public class MyDataAdapter extends SuperBaseAdapter<VehicleObj> {

    public MyDataAdapter(Context context, List<VehicleObj> data){
        super(context,data);
    }
    @Override
    protected void convert(BaseViewHolder holder, VehicleObj item, int position) {
        holder.setText(R.id.vehicle_number,item.getVehicleNumber());
        holder.setText(R.id.vehicle_line,item.getVehicleLine());
        holder.setText(R.id.vehicle_time,item.getVehicleTime());
        if(item.getVehicleLevel()=="1"){
            holder.setBackgroundResource(R.id.img_vehicle,R.drawable.vehicle_red);
            holder.setVisible2(R.id.rl_vehicle_red,true);
            holder.setVisible2(R.id.rl_vehicle_orange,true);
            holder.setVisible2(R.id.rl_vehicle_yellow,true);
        }else if(item.getVehicleLevel()=="2"){
            holder.setBackgroundResource(R.id.img_vehicle,R.drawable.vehicle_orange);
            holder.setVisible2(R.id.rl_vehicle_red,false);
            holder.setVisible2(R.id.rl_vehicle_orange,true);
            holder.setVisible2(R.id.rl_vehicle_yellow,true);
        }else{
            holder.setBackgroundResource(R.id.img_vehicle,R.drawable.vehicle_yellow);
            holder.setVisible2(R.id.rl_vehicle_red,false);
            holder.setVisible2(R.id.rl_vehicle_orange,false);
            holder.setVisible2(R.id.rl_vehicle_yellow,true);
        }
    }

    @Override
    protected int getItemViewLayoutId(int position, VehicleObj item) {
        return R.layout.vehicle_item;
    }

}
